export const set = (key, data) => {
  window.sessionStorage.setItem(key, JSON.stringify(data))
}

export const get = key => {
  return JSON.parse(window.sessionStorage.getItem(key))
}

export const gettime = data => {
  let H = addzero(new Date(data).getHours())
  let M = addzero(new Date(data).getMinutes())
  let yy = String(new Date(data).getFullYear()).slice(2, 4)
  let mm = addzero(new Date(data).getMonth() + 1)
  let dd = new Date(data).getDate()
  return yy + '/' + mm + '/' + dd + ' ' + H + ':' + M
}

export const addzero = num => {
  if (num < 9) {
    return '0' + num
  } else {
    return num
  }
}
